package com.lg.customRxJava;




public final class Schedulers {
    static final com.lg.customRxJava.Scheduler IO = null;
    static volatile Function<? super Scheduler, ? extends Scheduler> onIoHandler;

    public static com.lg.customRxJava.Scheduler io() {
        return onIoScheduler(IO);
    }

    public static com.lg.customRxJava.Scheduler onIoScheduler( com.lg.customRxJava.Scheduler defaultScheduler) {
        Function<? super com.lg.customRxJava.Scheduler, ? extends com.lg.customRxJava.Scheduler> f = onIoHandler;
        if (f == null) {
            return defaultScheduler;
        }
        return apply(f, defaultScheduler);
    }


    static <T, R> R apply(Function<T, R> f,  T t) {
        try {
            return f.apply(t);
        } catch (Throwable ex) {
            throw wrapOrThrow(ex);
        }
    }


    public static RuntimeException wrapOrThrow(Throwable error) {
        if (error instanceof Error) {
            throw (Error)error;
        }
        if (error instanceof RuntimeException) {
            return (RuntimeException)error;
        }
        return new RuntimeException(error);
    }
}

